package com.ruiysoft.pub.core;

import com.alibaba.fastjson.JSON;

/**
 * Created by 化增光 on 2017/11/7.
 */
public class Result<T> {
    private String bizCode = ResultCode.CODE_COMMON_ERROR;
    private String bizMessage;
    private T data;

    public Result setBizCode(String code) {
        this.bizCode = code;
        return this;
    }

    public boolean isSuccess() {
        if (this.getBizCode().equals(ResultCode.CODE_SUCCESS)){
            return true;
        }else{
            return false;
        }
    }

    public Result setBizMessage(String bizMessage) {
        this.bizMessage = bizMessage;
        return this;
    }

    public T getData() {
        return data;
    }

    public Result setData(T data) {
        this.data = data;
        return this;
    }

    public String getBizCode() {
        return bizCode;
    }

    public String getBizMessage() {
        return bizMessage;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
